// 2025/8/14
// kotori和迷宫

#include <iostream>
#include <vector>
#include <queue>
using namespace std;

vector<int> dx = {-1, 1, 0, 0};
vector<int> dy = {0, 0, -1, 1};

int main() {
    int m, n; cin >> m >> n;
    vector<vector<int>> visited(m, vector<int>(n, -1));
    queue<pair<int, int>> q;
    vector<string> matrix(m, string(n, 0));
    for(int i = 0; i < m; i++)
    {
        for(int j = 0; j < n; j++)
        {
            cin >> matrix[i][j];
            if(matrix[i][j] == 'k')
            {
                q.emplace(i, j);
                matrix[i][j] = '*';
                visited[i][j] = 0;
            }
        }
    }

    int ans = 0, cloest = -1;
    while(!q.empty())
    {
        auto [x, y] = q.front();
        q.pop();

        if(matrix[x][y] == 'e')
        {
            ans++;
            if(cloest == -1)
                cloest = visited[x][y];
            continue;
        }
        
        for(int i = 0; i < 4; i++)
        {
            int nx = x + dx[i], ny = y + dy[i];
            if(nx >= 0 && nx < m && ny >= 0 && ny < n && 
                matrix[nx][ny] != '*' && visited[nx][ny] == -1)
            {
                visited[nx][ny] = visited[x][y] + 1;
                q.emplace(nx, ny);
            }
        }
    }

    if(ans == 0)
        cout << -1 << endl;
    else
        cout << ans << " " << cloest << endl;
}
// 64 位输出请用 printf("%lld")